//
//  NSThread+x.m
//  iVideo
//
//  Created by baboy on 13-12-9.
//  Copyright (c) 2013年 baboy. All rights reserved.
//

#import "NSThread+x.h"

@implementation NSThread(x)
+ (void) runOnMainQueue:(void (^)(void))block
{
	if ([NSThread isMainThread])
	{
		block();
	}
	else
	{
		dispatch_sync(dispatch_get_main_queue(), block);
	}
}

+ (void)runOnMainQueue:(void (^)(void))block withDelay:(float)delay{
    dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
    dispatch_after(delayTime, dispatch_get_main_queue(), ^(void){
        block();
    });
}
@end
